//
//  BDGoumaiJiluTableViewCell.m
//  BadBoy
//
//  Created by wen on 2017/4/26.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDGoumaiJiluTableViewCell.h"

@interface BDGoumaiJiluTableViewCell ()

@property (nonatomic, strong) UIView *upLine;
@property (nonatomic, strong) UIView *downLine;

@end

@implementation BDGoumaiJiluTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    style = UITableViewCellStyleValue1;
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
    }
    return self;
}

- (void)configeWithModel:(id)model{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model[@"cover"]] placeholderImage:[UIImage imageNamed:@"shop_pic"]];
    self.textLabel.text = model[@"title"];
    
    NSDate *curDate = [NSDate dateWithTimeIntervalSince1970:[model[@"created_at"] floatValue]];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateStr = [formatter stringFromDate:curDate];
    self.detailTextLabel.text = [NSString stringWithFormat:ASLocalizedString(@"购买时间：%@"), dateStr];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.size = CGSizeMake(112, 70);
    self.imageView.left = 10;
    self.imageView.centerY = self.height / 2.0;
    
    self.textLabel.font = [UIFont systemFontOfSize:15];
    self.textLabel.textColor = [UIColor colorWithHexString:@"#101010"];
    [self.textLabel sizeToFit];
    self.textLabel.left = self.imageView.right + 10;
    self.textLabel.bottom = self.imageView.centerY - 5;
    
    self.detailTextLabel.font = [UIFont systemFontOfSize:14];
    self.detailTextLabel.textColor = [UIColor colorWithHexString:@"#767676"];
    [self.detailTextLabel sizeToFit];
    self.detailTextLabel.left = self.textLabel.left;
    self.detailTextLabel.top = self.imageView.centerY + 5;
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
//    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    self.downLine.backgroundColor = kBDColorGray;
    self.downLine.size = CGSizeMake(self.width, 0.5);
    self.downLine.bottom = self.height;
    
    self.upLine.backgroundColor = kBDColorGray;
    self.upLine.size = CGSizeMake(self.width, 0.5);
    if (self.isFirst == YES) {
        self.upLine.hidden = NO;
    }else{
        self.upLine.hidden = YES;
    }
}

- (UIView *)upLine{
    if (!_upLine) {
        self.upLine = [[UIView alloc] init];
        [self.contentView addSubview:_upLine];
    }
    return _upLine;
}

- (UIView *)downLine{
    if (!_downLine) {
        self.downLine = [[UIView alloc] init];
        [self.contentView addSubview:_downLine];
    }
    return _downLine;
}

@end
